package dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import util.Utilities;
import vo.OrderListVO;
import vo.OrderVO;

public class BusinessOrderDAO {

private SqlMapClientTemplate client;
	
	public BusinessOrderDAO(){}
	
	public BusinessOrderDAO(SqlMapClientTemplate client){
		this.client = client;
	}
	
	public ArrayList<OrderListVO> selectAllOrderList(String member_id) throws SQLException{
		System.out.println("DAO : "+member_id);
		return (ArrayList<OrderListVO>) client.queryForList("businessOrderSQL.selectAllBusinessOrderList", member_id);
	}
	
	public void updateAcceptOrder(HashMap<String, String> id) throws SQLException{
		client.update("businessOrderSQL.updateAcceptBusinessOrder", id);
	}
	
	public void updateTranslateOrder(HashMap<String, String> id) throws SQLException{
		client.update("businessOrderSQL.updateTranslateBusinessOrder", id);
	}
	
	public void updateCompleteOrder(HashMap<String, String> id) throws SQLException{
		client.update("businessOrderSQL.updateCompleteBusinessOrder", id);
	}
	
	public ArrayList<String> selectOrderId(String member_id) throws SQLException{
		return (ArrayList<String>)client.queryForList("businessOrderSQL.selectOrderId", member_id);
	}
	
	public OrderVO selectOrderVOById(String order_id) throws SQLException{
		return (OrderVO)client.queryForObject("businessOrderSQL.selectOrderVOList", order_id);
	}
	
	public ArrayList<OrderListVO> selectOrderListByOrderId(HashMap<String, String> map) throws SQLException{
		ArrayList<OrderListVO> list = (ArrayList<OrderListVO>)client.queryForList("businessOrderSQL.selectOrderListByOrderId", map);
		for (OrderListVO vo : list) {
			if (vo.getResult_time() != null) {
				vo.setResult_time(util.Utilities.getDateTimeDot(vo.getResult_time()));
			}
		}
		
		return list;
	}
}
